package com.cykj.user.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cykj.user.domain.Customer;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface CustomerMapper extends BaseMapper<Customer> {

    /**根据ID查询用户*/
    Customer selectById(Integer id);

    /**查询用户列表*/
    List<Customer> selectCtList(Customer ct);

    /**新增用户*/
    int insertCt(Customer ct);

    /**更新用户信息*/
    int updateCt(Customer ct);


    /**根据ID删除用户*/
    int deleteCtById(Integer id);

    /**批量删除用户*/
    int deleteCtByIds(Integer[] ids);

    /**统计符合条件的用户数量*/
    int selectCount(@Param("ew") QueryWrapper<Customer> queryWrapper);

    /**根据条件查询单个用户*/
    Customer selectOne(@Param("ew") QueryWrapper<Customer> queryWrapper);

    /**更新用户头像*/
    @Update("UPDATE ct SET avatar = #{avatar} WHERE id = #{userId}")
    int updateAvatar(@Param("userId") String userId, @Param("avatar") String avatar);

    /**更新用户名*/
    @Update("UPDATE ct SET name = #{username} WHERE id = #{userId}")
    int updateUsername(@Param("userId") String userId, @Param("username") String username);
    //更新黑名单状态
    @Update("UPDATE ct SET is_blacklisted = #{isBlacklisted} WHERE id = #{userId}")
    int updateBlacklistStatus(@Param("userId") Integer userId, @Param("isBlacklisted") Integer isBlacklisted);
}